const Bus = new Vue;

Vue.component('Message',{
    template:`
    <div class="alert-wrapper" v-if="id" :key="id">
        <div :class="'alert alert-'+type">{{content}}</div>
    </div>
    `,
    data(){
        return{
            id:null,
            content:null,
            type:null
        }
    },
    mounted(){
        Bus.$on('m',(content,type = 'danger')=>{
            this.id = Date.now();
            this.content = content;
            this.type = type;

            let timer = setTimeout(()=>{
                this.id = null;
                this.content = null;
                this.type = null;
            },3000)
        })
    }
})
